import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 报表消息推送配置信息 */
export interface ReportConfig {
          id: number; // id
          reportId?: number; // 父表id
          name?: string; // 名称
          targetValue: number; // 目标值
          dutyUserId: string; // 负责人
          dutyUserName: string; // 负责人
}

/** 报表汇总信息 */
export interface ReportView {
          id: number; // id
          name?: string; // 名称
          url: string; // 链接
          parentId?: number; // 父id
          sort?: number; // 显示顺序
          title: string; // 副标题
          icon: string; // 图标
          color: string; // 背景颜色
            reportconfigs?: ReportConfig[]
}

// 报表汇总 API
export const ReportViewApi = {
  // 查询报表汇总分页
  getReportViewPage: async (params: any) => {
    return await request.get({ url: `/business/report-view/page`, params })
  },

  // 查询报表汇总详情
  getReportView: async (id: number) => {
    return await request.get({ url: `/business/report-view/get?id=` + id })
  },

  // 新增报表汇总
  createReportView: async (data: ReportView) => {
    return await request.post({ url: `/business/report-view/create`, data })
  },

  // 修改报表汇总
  updateReportView: async (data: ReportView) => {
    return await request.put({ url: `/business/report-view/update`, data })
  },

  // 删除报表汇总
  deleteReportView: async (id: number) => {
    return await request.delete({ url: `/business/report-view/delete?id=` + id })
  },

  /** 批量删除报表汇总 */
  deleteReportViewList: async (ids: number[]) => {
    return await request.delete({ url: `/business/report-view/delete-list?ids=${ids.join(',')}` })
  },

  // 导出报表汇总 Excel
  exportReportView: async (params) => {
    return await request.download({ url: `/business/report-view/export-excel`, params })
  },

// ==================== 子表（报表消息推送配置） ====================

  // 获得报表消息推送配置列表
  getReportConfigListByReportId: async (reportId) => {
    return await request.get({ url: `/business/report-view/report-config/list-by-report-id?reportId=` + reportId })
  }
}